/*
 * Created on Nov 5, 2003
 *
 */
package dnl.util.ui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.LayoutManager;

import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

/**
 * @author Daniel Or
 */
public final class Panels {

	private Panels() {}

	public static JPanel newSeparatorPanel(int orientation, int size, Color color){
		JPanel jp = new JPanel();
		Dimension d = jp.getPreferredSize();
		Dimension m = new Dimension();
		if(orientation == SwingConstants.HORIZONTAL){
			m.height = size;
			d.height = size;
			m.width = Integer.MAX_VALUE;
			d.width = 0;
		}
		else {
			m.width = size;
			d.width = size;
			m.height = Integer.MAX_VALUE;
			d.height = 0;
		}
		jp.setPreferredSize(d);
		jp.setMaximumSize(m);
		jp.setBackground(color);
		return jp;
	}
	
	
    /**
     * 
     * @param jcomp
     * @return
     */
    public static JPanel newPanel(JComponent jcomp){
        JPanel jp = new JPanel();
        jp.add(jcomp);
        return jp;
    }

    /**
     * 
     * @param jcomp
     * @param lm
     * @return
     */
    public static JPanel newPanel(JComponent jcomp, LayoutManager lm){
        JPanel jp = new JPanel(lm);
        jp.add(jcomp);
        return jp;
    }
}
